﻿using SubhadraSolutions.Sharp.Utils.Data;
using SubhadraSolutions.Sharp.Utils.Data.Helpers;
using System.IO;

namespace SubhadraSolutions.Sharp.Logging.LogSubscribers.FileSystem
{
    public class ExcelFileLogSubscriber : AbstractStructuredFileLogSubscriber
    {
        public ExcelFileLogSubscriber()
        {
            newFileSizeThreshold = 0;
        }

        protected override void writeFileHeader(StreamWriter writer, DataReaderDataTableAdapter adapter)
        {
            ExcelHelper.WriteDataTableOrDataReader(adapter, writer.BaseStream);
        }

        protected override void writeRows(StreamWriter writer, DataReaderDataTableAdapter adapter)
        {
            ExcelHelper.AppendDataTableOrDataReader(adapter, writer.BaseStream);
        }
    }
}